package it.uniroma3.dia.accesso;

import it.uniroma3.dia.util.LoadProperties;
import winterwell.jtwitter.OAuthSignpostClient;
import winterwell.jtwitter.Twitter;

/*restituisce in un wrapper l'oggetto Twitter responsabile di interfacciarsi con
 * le api Twitter
 */
public class TwitterFactory {
	
	private static final String OAUTH_KEY = LoadProperties.getConsumerKey();
	private static final String OAUTH_SECRET = LoadProperties.getConsumerSecret();
	private static final String ACCESS_TOKEN = LoadProperties.getAccessToken();
	private static final String TOKEN_SECRET = LoadProperties.getTokenSecret();
	private static TwitterFactory instance;


	public TwitterWrapper getTwitterWrapper() {
		OAuthSignpostClient oauthClient = new OAuthSignpostClient(OAUTH_KEY, OAUTH_SECRET,ACCESS_TOKEN, TOKEN_SECRET);
		Twitter twitter = new Twitter("AccounDia", oauthClient);
		TwitterWrapper twitterWrap = new TwitterWrapper(twitter);
		return twitterWrap; 
	}

	public static TwitterFactory getInstance() {
		if (instance == null)
			instance = new TwitterFactory();
		return instance;
	}

}
